<?php

/**
 * Project: CrazyPoems
 * Author: Alexandru
 * Date: 11/01/2009
 * File: rss.php
 */

// Load default settings.
require('inc/config.php');
require('inc/functions.misc.php');

header("Content-Type: application/xml; charset=utf-8");

echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE channel [ 
<!ENTITY oacute "&#211;">
<!ENTITY nbsp "&#160;">
]>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
				<title>CrazyPoems.net Poezii nebune, intra si compune!</title>
				<description>Dupa cum spune si numele, acest site este pentru autorii de poezii nebunesti, acele poezii amuzante care iti vin in minte, si pentru cititorii care nu sunt prea inspirati sa compuna dar vor sa vada ceva placut si haios! Pune-ti imaginatia la incercare si scrie primele rime care iti vin in cap!</description>
				<link>http://'.$_SERVER['HTTP_HOST'].BASE_URL.'</link>
				<copyright>2009 atrandafir. Contact: atrandafirc - at - yahoo.com</copyright>
				<atom:link href="http://'.$_SERVER['HTTP_HOST'].BASE_URL.'rss.php" rel="self" type="application/rss+xml" />';
				
	$q = mysql_query("SELECT * FROM ".TABLE_POEMS." WHERE visible = 'Y' ORDER BY id DESC LIMIT 0,25") or die(mysql_error());
	while ($r = mysql_fetch_assoc($q)) {
	
	$pubDate=strtotime($r['publish_date']);
		echo "\n\r".'<item>
					 <title>'. str_replace("&","&amp;",$r["title"]) .'</title>
					 <link>'.get_link('poem', array('id' => $r['id'], 'title' => $r['title'], 'category' => $r['category']), true).'</link>
					 <pubDate>' . @date(DATE_ATOM, $pubDate) . '</pubDate>
					 <description><![CDATA['. nl2br($r["poem"]) .']]></description>
					</item>';
	}
				
echo '</channel>
</rss>';

// <title>'. htmlentities($r["title"], ENT_QUOTES, "UTF-8" ) .'</title>
// 					 <description><![CDATA['. nl2br(htmlentities($r["poem"], ENT_QUOTES, "UTF-8" )) .']]></description>

// End page.
require('inc/end.php');
?>